<%@ taglib uri="http://struts.apache.org/tags-bean" prefix="bean" %>
<%@ taglib uri="http://struts.apache.org/tags-html" prefix="html" %>
<%@ taglib uri="http://struts.apache.org/tags-logic" prefix="logic" %>

<%@ page import="net.lwf.web.constant.IWebConstant, net.lwf.common.constant.ICommonConstant"%>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<HTML>
	<HEAD>
		<link href="<%=request.getContextPath()%>/style/global.css" rel="stylesheet" type="text/css">
			   <script type="text/javascript" language="javascript" src="<%=request.getContextPath()%>/javascript/common.js"></script>
		<TITLE>My Teaching Buddy</TITLE>
		<script>
		  function getFocus() {
			  var focusControl = document.forms["haform"].elements["preferences.name"];
			
			  if (focusControl != null && focusControl.type == "text") {
			     focusControl.focus();
			  }		  
		  }
		
		   function submitPreferences(action) {
		     // var elemvalue = document.forms["haform"].elements["preferences.name"].value;
		      //if(elemvalue == null || elemvalue.length == 0) {
		        // alert('Enter your name please......');
		         //document.forms["haform"].elements["preferences.name"].focus();
		         //return false;
		      //}
		      var level = getCheckedRadio('preferences.level');
		      if(level == null || level.length == 0) {
		          alert('Please select your level......');
		          return false;
		      }
		      submitForm(action);
		   }
		</script>
	</HEAD>
	<BODY onload="getFocus()">
	<html:form action="/home">
		<table align="center">
          <logic:equal name="haform" property="showPreferences" value="true">
            <tr>
               <td colspan="3" align="center"><h1>User Preferences</h1></td>
            </tr>  
            <tr>
               <td colspan="3">&nbsp;</td>
            </tr>
            <tr>
               <td colspan="3">
                  <fieldset>
                  	 <legend>Enter/Change your preferences</legend>
                  	 <table>
                  	    <tr>
                  	       <td colspan="2">&nbsp;</td>
                  	    </tr>                  	 
                  	    <tr>
                  	       <td class="formLabel">Are you a pre-schooler?</td>
                  	       <td class="formValue">
                  	          <html:radio property="preferences.level" value="<%=IWebConstant.PRE_SCHOOL%>" /> &nbsp;&nbsp;Yes
                  	          <html:radio property="preferences.level" value="<%=IWebConstant.NOT_PRE_SCHOOL%>" /> &nbsp;&nbsp;No
                  	       </td>
                  	    </tr>
                  	    <tr>
                  	       <td colspan="2">&nbsp;</td>
                  	    </tr>
                  	    <tr>
                  	       <td class="formLabel">Do you want to see the answer?</td>
                  	       <td class="formValue">
                  	          <html:radio property="preferences.seeAnswer" value="<%=ICommonConstant.YES%>"/> &nbsp;&nbsp;Yes
                  	          <html:radio property="preferences.seeAnswer" value="<%=ICommonConstant.NO%>"/> &nbsp;&nbsp;No
                  	       </td>
                  	    </tr>
                  	    <tr>
                  	       <td colspan="2">&nbsp;</td>
                  	    </tr>
                  	    <tr>
                  	       <td class="formLabel">Attempts to answer a question:</td>
                  	       <td>
		                      <html:select property="preferences.attempts">
		                          <html:options property="lstAttempts"/>
		                      </html:select>                  	       
                  	       </td>
                  	    </tr>
                  	    <tr>
                  	       <td colspan="2">&nbsp;</td>
                  	    </tr>
                  	    <tr>
                  	       <td colspan="2" align="right">
                  	          <input type="button" name="Submit" value="Submit" onClick="submitPreferences('/home.do?action=save')"/>
                  	       </td>
                  	    </tr>
                  	 </table>
                  </fieldset>
               </td>
            </tr>     
           </logic:equal>
		   <logic:equal name="haform" property="showPreferences" value="false">
            <tr>
               <td colspan="3">&nbsp;</td>
            </tr>		   
            <tr>
	           <td align="center" class="description-small">
					<p>This site is aimed to make you more familiarize various concepts by iterative process. You may attempt a particular concept(s) OR switch
					   concepts as many times as you can. At the end you may verify your scores by clicking the 'see' link under the Score tab.</p>

	           		<p>If you have any comments or suggestions, please use the link at the bottom left hand corner (in the following pages) to send your feedback.</p>
	           		<p>Your feedback is appreciated inorder this site to be improved further</p>
	
	           </td>
            </tr>  

            </logic:equal>
                       
		</table>
    </html:form>		
	</BODY>
</HTML>
